import React, { useEffect, useState, useCallback } from 'react';
import { Table, Button, Card, Modal, Form, message, Tabs, Select, Input } from 'antd';
import type { ColumnsType } from 'antd/es/table';
import type { TablePaginationConfig } from 'antd/es/table';
import { SignatureItem, CallSignatureItem, OrganizationItem, CasResult } from 'admin/schema/Cas';
import {
  getSignatures,
  addSignature,
  updateSignature,
  deleteSignature,
  auditSignature,
  getCasOrganizationsShow,
  getCallSignatures,
  addCallSignature,
  updateCallSignature,
  deleteCallSignature,
  auditCallSignature,
} from 'admin/servers/modules/Cas';
import SignatureFormModal from '../components/SignatureFormModal';
import CallSignatureFormModal from '../components/CallSignatureFormModal';
import SignatureAuditModal from '../components/SignatureAuditModal';
import { useSelector } from 'react-redux';
import { flatten, isEmpty, map, omit, reduce, some, find, startsWith, debounce } from 'lodash';
import { UploadFile } from 'antd/es/upload/interface';
import { getFileList } from '../utils';
import qs from 'query-string';

const { TabPane } = Tabs;

interface SignatureFormValues {
  name: string;
  type: string;
  organizationId: string;
  description: string;
  phone: string;
  certificatePath: UploadFile[];
  idCardFrontImagePath: UploadFile[];
  idCardBackImagePath: UploadFile[];
  powerOfAttorney: UploadFile[];
}

interface CallSignatureFormValues {
  name: string;
  organization: string;
  scriptScenario: UploadFile[];
  concurrency: number;
  securityCommitment: UploadFile[];
}

interface AuditFormValues {
  auditStatus: string;
  remark: string;
}

const Signatures: React.FC = () => {
  const [activeTab, setActiveTab] = useState(
    (qs.parse(location.search)?.activeTab as string) || 'industry'
  );
  const [loading, setLoading] = useState(false);
  const [signatures, setSignatures] = useState<SignatureItem[]>([]);
  const [callSignatures, setCallSignatures] = useState<CallSignatureItem[]>([]);
  const [modalVisible, setModalVisible] = useState(false);
  const [modalTitle, setModalTitle] = useState('新增签名');
  const [form] = Form.useForm<SignatureFormValues>();
  const [callForm] = Form.useForm<CallSignatureFormValues>();
  const [auditForm] = Form.useForm<AuditFormValues>();
  const [editingSignature, setEditingSignature] = useState<SignatureItem | null>(null);
  const [editingCallSignature, setEditingCallSignature] = useState<CallSignatureItem | null>(null);
  const [auditModalVisible, setAuditModalVisible] = useState(false);
  const [auditingId, setAuditingId] = useState('');
  const [pagination, setPagination] = useState({
    current: 1,
    pageSize: 10,
    total: 0,
  });
  const userInfo = useSelector((state: any) => state.loginInfo);
  const [organizations, setOrganizations] = useState<
    Omit<OrganizationItem, 'children' | 'description'>[]
  >([]);
  const [searchForm] = Form.useForm();

  // 获取签名列表
  const fetchSignatures = useCallback(
    async (page = 1, pageSize = 10, params = {}) => {
      setLoading(true);
      try {
        const response = await getSignatures({
          pageNo: page - 1,
          pageSize,
          type: activeTab === 'industry' ? '行业短信' : '靶向短信',
          name: params.name || undefined,
          status: params.status,
        });
        if (response.status === 200) {
          const { content, totalElements, number } = response.data;
          setSignatures(content);
          setPagination(prev => ({
            ...prev,
            current: number + 1,
            pageSize,
            total: totalElements,
          }));
        }
      } catch (error) {
        console.error('获取签名列表出错:', error);
      } finally {
        setLoading(false);
      }
    },
    [activeTab]
  );

  // 获取呼叫签名列表
  const fetchCallSignatures = useCallback(async (page = 1, pageSize = 10, params = {}) => {
    setLoading(true);
    try {
      const response = await getCallSignatures(page - 1, pageSize, {
        name: params.name || undefined,
        status: params.status,
      });
      if (response.status === 200) {
        const { content, totalElements, number } = response.data;
        setCallSignatures(content);
        setPagination(prev => ({
          ...prev,
          current: number + 1,
          pageSize,
          total: totalElements,
        }));
      }
    } catch (error) {
      console.error('获取呼叫签名列表出错:', error);
    } finally {
      setLoading(false);
    }
  }, []);

  // 获取单位列表
  const fetchOrganizations = useCallback(async () => {
    try {
      const response = await getCasOrganizationsShow();
      if (response.status === 200) {
        setOrganizations(response.data);
      }
    } catch (error) {
      console.error('获取单位列表出错:', error);
    }
  }, []);

  useEffect(() => {
    if (activeTab === 'call') {
      fetchCallSignatures();
    } else {
      fetchSignatures();
    }
    fetchOrganizations();
  }, [fetchSignatures, fetchCallSignatures, fetchOrganizations, activeTab]);

  const handleTableChange = useCallback(
    (newPagination: TablePaginationConfig) => {
      if (activeTab === 'call') {
        fetchCallSignatures(
          newPagination.current,
          newPagination.pageSize,
          searchForm.getFieldsValue()
        );
      } else {
        fetchSignatures(newPagination.current, newPagination.pageSize, searchForm.getFieldsValue());
      }
    },
    [activeTab, fetchCallSignatures, searchForm, fetchSignatures]
  );

  const handleAdd = useCallback(() => {
    setModalTitle('新增签名');
    if (activeTab === 'call') {
      setEditingCallSignature(null);
      callForm.resetFields();
    } else {
      setEditingSignature(null);
      form.resetFields();
      form.setFieldsValue({
        type: activeTab === 'industry' ? '行业短信' : '靶向短信',
      });
    }
    setModalVisible(true);
  }, [form, callForm, activeTab]);

  const handleEdit = useCallback(
    (record: SignatureItem | CallSignatureItem) => {
      if (record.status !== 'REJECTED') {
        message.error('只有被拒绝的签名才能修改');
        return;
      }
      setModalTitle('编辑签名');
      if (activeTab === 'call') {
        const callRecord = record as CallSignatureItem;
        setEditingCallSignature(callRecord);
        callForm.setFieldsValue({
          name: callRecord.name,
          organization: callRecord.organization,
          concurrency: callRecord.concurrency,
          scriptScenario: getFileList(callRecord.scriptScenario),
          securityCommitment: getFileList(callRecord.securityCommitment),
        });
      } else {
        const smsRecord = record as SignatureItem;
        setEditingSignature(smsRecord);
        form.setFieldsValue({
          name: smsRecord.name,
          type: smsRecord.type,
          organizationId: smsRecord.organizationId,
          description: smsRecord.description,
          phone: smsRecord.phone,
          certificatePath: getFileList(smsRecord.certificatePath),
          idCardFrontImagePath: getFileList(smsRecord.idCardFrontImagePath),
          idCardBackImagePath: getFileList(smsRecord.idCardBackImagePath),
          powerOfAttorney: getFileList(smsRecord.powerOfAttorney),
        });
      }
      setModalVisible(true);
    },
    [form, callForm, activeTab]
  );

  const handleDelete = useCallback(
    (record: SignatureItem | CallSignatureItem) => {
      if (record.status !== 'REJECTED') {
        message.error('只有被拒绝的签名才能删除');
        return;
      }
      Modal.confirm({
        title: '确认删除',
        content: `确定要删除签名"${record.name}"吗？`,
        onOk: async () => {
          try {
            let response;
            if (activeTab === 'call') {
              response = await deleteCallSignature(record.id);
            } else {
              response = await deleteSignature(record.id);
            }
            if (response.status === 200) {
              message.success('删除成功');
              if (activeTab === 'call') {
                fetchCallSignatures();
              } else {
                fetchSignatures();
              }
            }
          } catch (error) {
            console.error('删除签名出错:', error);
          }
        },
      });
    },
    [fetchSignatures, fetchCallSignatures, activeTab]
  );

  const handleModalOk = useCallback(
    debounce(async () => {
      try {
        if (activeTab === 'call') {
          const values = await callForm.validateFields();

          // 处理文件上传
          const fileFields = ['scriptScenario', 'securityCommitment'];
          const fileValues: any = reduce(
            fileFields,
            (acc, file) => {
              acc[file] = JSON.stringify(
                flatten(
                  map(values[file], (item: any) => {
                    if (item.status === 'done' && item.response.status === 200) {
                      return item.response.data;
                    }
                    return [];
                  }).filter((item: any) => !isEmpty(item))
                )
              );
              return acc;
            },
            {}
          );

          // 检查必需的文件是否已上传
          if (some(fileValues, (value: any) => value === '[]' || value === '""')) {
            message.error('请上传所有必需的文件');
            return;
          }

          const data = {
            ...values,
            scriptScenario: fileValues.scriptScenario,
            securityCommitment: fileValues.securityCommitment,
          };

          if (editingCallSignature) {
            // 更新呼叫签名
            const response = await updateCallSignature(editingCallSignature.id, data);
            if (response.status === 200) {
              message.success('更新成功');
              setModalVisible(false);
              fetchCallSignatures(
                pagination.current,
                pagination.pageSize,
                searchForm.getFieldsValue()
              );
            }
          } else {
            // 新增呼叫签名
            const response = await addCallSignature(data);
            if (response.status === 200) {
              message.success('添加成功');
              setModalVisible(false);
              fetchCallSignatures(
                pagination.current,
                pagination.pageSize,
                searchForm.getFieldsValue()
              );
            }
          }
        } else {
          const values = await form.validateFields();
          // 确保所有必需的文件都已上传
          const fileFields = [
            'idCardFrontImagePath',
            'idCardBackImagePath',
            'certificatePath',
            'powerOfAttorney',
            'powerOfLetter',
          ];

          const fileValues: any = reduce(
            fileFields,
            (acc, file) => {
              acc[file] = JSON.stringify(
                flatten(
                  map(values[file], (item: any) => {
                    if (item.status === 'done' && item.response.status === 200) {
                      return item.response.data;
                    }
                    return [];
                  }).filter((item: any) => !isEmpty(item))
                )
              );
              return acc;
            },
            {}
          );

          if (some(fileValues, (value: any) => value === '[]' || value === '""')) {
            message.error('请上传所有必需的文件');
            return;
          }

          const data = {
            ...values,
            certificatePath: fileValues.certificatePath,
            idCardBackImagePath: fileValues.idCardBackImagePath,
            idCardFrontImagePath: fileValues.idCardFrontImagePath,
            powerOfAttorney: fileValues.powerOfAttorney,
            powerOfLetter: fileValues.powerOfLetter,
          };

          if (editingSignature) {
            const response = await updateSignature(editingSignature.id, data);
            if (response.status === 200) {
              message.success('更新成功');
              setModalVisible(false);
              fetchSignatures(pagination.current, pagination.pageSize, searchForm.getFieldsValue());
            }
          } else {
            const response = await addSignature({
              ...data,
              type: [data.type],
            });
            if (response.status === 200) {
              message.success('添加成功');
              setModalVisible(false);
              fetchSignatures(pagination.current, pagination.pageSize, searchForm.getFieldsValue());
            }
          }
        }
      } catch (error) {
        console.error('表单提交出错:', error);
        message.error('表单提交失败，请填写必填项');
      }
    }, 500),
    [
      activeTab,
      callForm,
      editingCallSignature,
      fetchCallSignatures,
      pagination,
      searchForm,
      form,
      editingSignature,
      fetchSignatures,
    ]
  );

  const handleAudit = useCallback(
    (record: SignatureItem | CallSignatureItem) => {
      if (activeTab === 'call') {
        setEditingCallSignature(record as CallSignatureItem);
      } else {
        setEditingSignature(record as SignatureItem);
      }
      setAuditingId(record.id);
      auditForm.resetFields();
      setAuditModalVisible(true);
    },
    [auditForm, activeTab]
  );

  const handleAuditOk = useCallback(
    debounce(async () => {
      try {
        const values = await auditForm.validateFields();
        let response: CasResult<any>;
        if (activeTab === 'call') {
          response = await auditCallSignature(auditingId, {
            ...values,
            auditBy: userInfo.id,
          });
        } else {
          response = await auditSignature(auditingId, {
            ...values,
            auditBy: userInfo.id,
          });
        }
        if (response.status === 200) {
          message.success('审核成功');
          setAuditModalVisible(false);
          if (activeTab === 'call') {
            fetchCallSignatures(
              pagination.current,
              pagination.pageSize,
              searchForm.getFieldsValue()
            );
          } else {
            fetchSignatures(pagination.current, pagination.pageSize, searchForm.getFieldsValue());
          }
        }
      } catch (error) {
        console.error('审核出错:', error);
      }
    }, 500),
    [
      auditForm,
      activeTab,
      auditingId,
      userInfo.id,
      fetchCallSignatures,
      pagination,
      searchForm,
      fetchSignatures,
    ]
  );

  const handleTabChange = (key: string) => {
    const url = new URL(location.href);
    url.searchParams.set('activeTab', key);
    history.pushState({}, '', url.toString());
    setActiveTab(key);
    setPagination(prev => ({ ...prev, current: 1 }));
    searchForm.resetFields();
  };

  const handleReset = debounce(() => {
    searchForm.resetFields();
    if (activeTab === 'call') {
      fetchCallSignatures();
    } else {
      fetchSignatures();
    }
  }, 500);

  const handleFinish = debounce((values: any) => {
    if (activeTab === 'call') {
      fetchCallSignatures(1, 10, values);
    } else {
      fetchSignatures(1, 10, values);
    }
  }, 500);

  const smsColumns: ColumnsType<SignatureItem> = [
    {
      title: '签名名称',
      dataIndex: 'name',
      key: 'name',
    },
    {
      title: '单位名称',
      dataIndex: 'organizationId',
      key: 'organizationId',
      render: organizationId => find(organizations, { id: organizationId })?.name || organizationId,
    },
    {
      title: '状态',
      dataIndex: 'status',
      key: 'status',
      render: (_, record) => {
        if (record.status === 'PENDING') {
          return '待审核';
        } else if (record.status === 'UNDER_REVIEW') {
          return '审核中';
        } else if (record.status === 'APPROVED') {
          return '审核通过';
        } else if (record.status === 'REJECTED') {
          return '审核驳回';
        }
        return record.status;
      },
    },
    {
      title: '描述',
      dataIndex: 'description',
      key: 'description',
      ellipsis: true,
    },
    {
      title: '创建时间',
      dataIndex: 'createdAt',
      key: 'createdAt',
      render: time => new Date(time).toLocaleString(),
    },
    {
      title: '操作',
      key: 'action',
      render: (_, record) => {
        if (
          record.status === 'REJECTED' &&
          some(userInfo?.permissions, permission =>
            startsWith(permission?.code, 'BUSINESS_AUDIT_SIGNATURE_APPLICATION')
          )
        ) {
          return (
            <>
              <Button type="link" onClick={() => handleAudit(record)}>
                查看
              </Button>
              <Button type="link" onClick={() => handleEdit(record)}>
                编辑
              </Button>
              <Button type="link" danger onClick={() => handleDelete(record)}>
                删除
              </Button>
            </>
          );
        }
        if (record.status === 'PENDING') {
          if (
            some(userInfo?.permissions, permission =>
              startsWith(permission?.code, 'BUSINESS_AUDIT_SIGNATURE_AUDIT_LEVEL1')
            )
          ) {
            return (
              <Button type="link" onClick={() => handleAudit(record)}>
                审核
              </Button>
            );
          } else {
            return (
              <Button type="link" onClick={() => handleAudit(record)}>
                查看
              </Button>
            );
          }
        }
        if (record.status === 'UNDER_REVIEW') {
          if (
            some(userInfo?.permissions, permission =>
              startsWith(permission?.code, 'BUSINESS_AUDIT_SIGNATURE_AUDIT_LEVEL2')
            )
          ) {
            return (
              <Button type="link" onClick={() => handleAudit(record)}>
                审核
              </Button>
            );
          } else {
            return (
              <Button type="link" onClick={() => handleAudit(record)}>
                查看
              </Button>
            );
          }
        }
        return (
          <Button type="link" onClick={() => handleAudit(record)}>
            查看
          </Button>
        );
      },
    },
  ];

  const callColumns: ColumnsType<CallSignatureItem> = [
    {
      title: '签名名称',
      dataIndex: 'name',
      key: 'name',
    },
    {
      title: '单位名称',
      dataIndex: 'organization',
      key: 'organization',
      render: organization => find(organizations, { id: organization })?.name || organization,
    },
    {
      title: '并发数',
      dataIndex: 'concurrency',
      key: 'concurrency',
    },
    {
      title: '状态',
      dataIndex: 'status',
      key: 'status',
      render: (_, record) => {
        if (record.status === 'PENDING') {
          return '待审核';
        } else if (record.status === 'UNDER_REVIEW') {
          return '审核中';
        } else if (record.status === 'APPROVED') {
          return '审核通过';
        } else if (record.status === 'REJECTED') {
          return '审核驳回';
        }
        return record.status;
      },
    },
    {
      title: '创建时间',
      dataIndex: 'createdAt',
      key: 'createdAt',
      render: time => new Date(time).toLocaleString(),
    },
    {
      title: '操作',
      key: 'action',
      render: (_, record) => {
        if (
          record.status === 'REJECTED' &&
          some(userInfo?.permissions, permission =>
            startsWith(permission?.code, 'BUSINESS_AUDIT_SIGNATURE_APPLICATION')
          )
        ) {
          return (
            <>
              <Button type="link" onClick={() => handleAudit(record)}>
                查看
              </Button>
              <Button type="link" onClick={() => handleEdit(record)}>
                编辑
              </Button>
              <Button type="link" danger onClick={() => handleDelete(record)}>
                删除
              </Button>
            </>
          );
        }
        if (record.status === 'PENDING') {
          if (
            some(userInfo?.permissions, permission =>
              startsWith(permission?.code, 'BUSINESS_AUDIT_SIGNATURE_AUDIT_LEVEL1')
            )
          ) {
            return (
              <Button type="link" onClick={() => handleAudit(record)}>
                审核
              </Button>
            );
          } else {
            return (
              <Button type="link" onClick={() => handleAudit(record)}>
                查看
              </Button>
            );
          }
        }
        if (record.status === 'UNDER_REVIEW') {
          if (
            some(userInfo?.permissions, permission =>
              startsWith(permission?.code, 'BUSINESS_AUDIT_SIGNATURE_AUDIT_LEVEL2')
            )
          ) {
            return (
              <Button type="link" onClick={() => handleAudit(record)}>
                审核
              </Button>
            );
          } else {
            return (
              <Button type="link" onClick={() => handleAudit(record)}>
                查看
              </Button>
            );
          }
        }
        return (
          <Button type="link" onClick={() => handleAudit(record)}>
            查看
          </Button>
        );
      },
    },
  ];

  return (
    <div style={{ padding: '24px' }}>
      <Card
        title="签名管理"
        bordered={false}
        bodyStyle={{ paddingTop: 5 }}
        extra={
          some(userInfo?.permissions, permission =>
            startsWith(permission?.code, 'BUSINESS_AUDIT_SIGNATURE_APPLICATION')
          ) && (
            <Button type="primary" onClick={handleAdd}>
              新增签名
            </Button>
          )
        }
      >
        <Tabs activeKey={activeTab} onChange={handleTabChange}>
          <TabPane tab="行业短信" key="industry">
            <Form
              layout="inline"
              form={searchForm}
              onFinish={handleFinish}
              style={{ marginBottom: '20px' }}
            >
              <Form.Item label="签名名称" name="name">
                <Input placeholder="请输入签名名称" />
              </Form.Item>
              <Form.Item label="状态" name="status">
                <Select placeholder="请选择状态" allowClear>
                  <Select.Option value="PENDING">待审核</Select.Option>
                  <Select.Option value="UNDER_REVIEW">审核中</Select.Option>
                  <Select.Option value="APPROVED">审核通过</Select.Option>
                  <Select.Option value="REJECTED">审核驳回</Select.Option>
                </Select>
              </Form.Item>
              <Form.Item>
                <Button type="primary" htmlType="submit">
                  搜索
                </Button>
                <Button style={{ marginLeft: 8 }} onClick={handleReset}>
                  重置
                </Button>
              </Form.Item>
            </Form>
            <Table
              columns={smsColumns}
              dataSource={signatures}
              rowKey="id"
              loading={loading}
              pagination={{
                ...pagination,
                showTotal: (total: number) => `共 ${total} 条`,
                showSizeChanger: true,
              }}
              onChange={handleTableChange}
            />
          </TabPane>
          <TabPane tab="靶向短信" key="target">
            <Form
              layout="inline"
              form={searchForm}
              onFinish={handleFinish}
              style={{ marginBottom: '20px' }}
            >
              <Form.Item label="签名名称" name="name">
                <Input placeholder="请输入签名名称" />
              </Form.Item>
              <Form.Item label="状态" name="status">
                <Select placeholder="请选择状态" allowClear>
                  <Select.Option value="PENDING">待审核</Select.Option>
                  <Select.Option value="UNDER_REVIEW">审核中</Select.Option>
                  <Select.Option value="APPROVED">审核通过</Select.Option>
                  <Select.Option value="REJECTED">审核驳回</Select.Option>
                </Select>
              </Form.Item>
              <Form.Item>
                <Button type="primary" htmlType="submit">
                  搜索
                </Button>
                <Button style={{ marginLeft: 8 }} onClick={handleReset}>
                  重置
                </Button>
              </Form.Item>
            </Form>
            <Table
              columns={smsColumns}
              dataSource={signatures}
              rowKey="id"
              loading={loading}
              pagination={{
                ...pagination,
                showTotal: (total: number) => `共 ${total} 条`,
                showSizeChanger: true,
              }}
              onChange={handleTableChange}
            />
          </TabPane>
          <TabPane tab="智能外呼" key="call">
            <Form
              layout="inline"
              form={searchForm}
              onFinish={handleFinish}
              style={{ marginBottom: '20px' }}
            >
              <Form.Item label="签名名称" name="name">
                <Input placeholder="请输入签名名称" />
              </Form.Item>
              <Form.Item label="状态" name="status">
                <Select placeholder="请选择状态" allowClear>
                  <Select.Option value="PENDING">待审核</Select.Option>
                  <Select.Option value="UNDER_REVIEW">审核中</Select.Option>
                  <Select.Option value="APPROVED">审核通过</Select.Option>
                  <Select.Option value="REJECTED">审核驳回</Select.Option>
                </Select>
              </Form.Item>
              <Form.Item>
                <Button type="primary" htmlType="submit">
                  搜索
                </Button>
                <Button style={{ marginLeft: 8 }} onClick={handleReset}>
                  重置
                </Button>
              </Form.Item>
            </Form>
            <Table
              columns={callColumns}
              dataSource={callSignatures}
              rowKey="id"
              loading={loading}
              pagination={{
                ...pagination,
                showTotal: (total: number) => `共 ${total} 条`,
                showSizeChanger: true,
              }}
              onChange={handleTableChange}
            />
          </TabPane>
        </Tabs>
      </Card>

      {activeTab === 'call' ? (
        <CallSignatureFormModal
          visible={modalVisible}
          title={modalTitle}
          onOk={handleModalOk}
          onCancel={() => {
            setModalVisible(false);
            setEditingCallSignature(null);
          }}
          editingSignature={editingCallSignature}
          form={callForm}
          orgTree={organizations}
        />
      ) : (
        <SignatureFormModal
          visible={modalVisible}
          title={modalTitle}
          onOk={handleModalOk}
          onCancel={() => {
            setModalVisible(false);
            setEditingSignature(null);
          }}
          editingSignature={editingSignature}
          orgTree={organizations}
          form={form}
        />
      )}

      <SignatureAuditModal
        title="审核签名"
        visible={auditModalVisible}
        onOk={handleAuditOk}
        onCancel={() => setAuditModalVisible(false)}
        form={auditForm}
        organizations={organizations}
        signature={activeTab === 'call' ? editingCallSignature : editingSignature}
        type={activeTab === 'call' ? 'call' : 'sms'}
        hasAuditPermission={
          activeTab === 'call'
            ? (some(userInfo?.permissions, permission =>
                startsWith(permission?.code, 'BUSINESS_AUDIT_SIGNATURE_AUDIT_LEVEL1')
              ) &&
                editingCallSignature?.status === 'PENDING') ||
              (some(userInfo?.permissions, permission =>
                startsWith(permission?.code, 'BUSINESS_AUDIT_SIGNATURE_AUDIT_LEVEL2')
              ) &&
                editingCallSignature?.status === 'UNDER_REVIEW')
            : (some(userInfo?.permissions, permission =>
                startsWith(permission?.code, 'BUSINESS_AUDIT_SIGNATURE_AUDIT_LEVEL1')
              ) &&
                editingSignature?.status === 'PENDING') ||
              (some(userInfo?.permissions, permission =>
                startsWith(permission?.code, 'BUSINESS_AUDIT_SIGNATURE_AUDIT_LEVEL2')
              ) &&
                editingSignature?.status === 'UNDER_REVIEW')
        }
      />
    </div>
  );
};

export default Signatures;
